home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
graphics
/
frxfiles
/
frxfiles.frm
< prev
next >
Wrap
Text File
|
1995-11-11
|
3KB
|
113 lines
VERSION 2.00
Begin Form Form1
BorderStyle = 3 'Fixed Double
Caption = "Extract Pictures"
ClientHeight = 1140
ClientLeft = 2055
ClientTop = 2715
ClientWidth = 4695
Height = 1920
Left = 1950
LinkTopic = "Form1"
ScaleHeight = 1140
ScaleWidth = 4695
Top = 2040
Width = 4905
Begin CommonDialog CMDialog1
Left = 315
Top = 1515
End
Begin Label Label1
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 9.75
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 315
Left = 885
TabIndex = 0
Top = 375
Width = 3420
End
Begin Menu mnuFile
Caption = "&File"
End
End
Option Explicit
Sub ExtractPictures (fname$)
Dim flong&, counter&, piclen&, c%
Dim hMem%, gptr&, newfile, handle1, handle2
Dim ret&, bmtest%, wmftest&
Dim ext As String * 4
Const WMF = &H9AC6CDD7
Const BM = &H4D42
c = 1
counter = 1
flong = FileLen(fname)
Open fname For Binary As #1
Do Until counter >= flong
Get #1, counter, piclen 'get length of picture
counter = counter + 4
If counter + piclen - 1 > flong Then Exit Do ' if its not a picture then piclen could be wrong, and you don't want to read past end of file
Get #1, counter, bmtest
If bmtest = BM Then 'check for bitmap
ext = ".bmp"
End If
If bmtest <> BM Then
Get #1, counter, wmftest 'not a bitmap check for metafile
If wmftest = WMF Then
ext = ".wmf"
Else
ext = ".ico" 'must be an icon
End If
End If
Seek #1, counter
handle1 = FileAttr(1, 2)
hMem = GlobalAlloc(GHND, piclen) 'pictures could be over 64K so get memory from global heap
gptr = GlobalLock(hMem)
ret = hread(handle1, gptr, piclen) 'might be over 64K so use hread
newfile = FreeFile
Open App.Path & "\fpic" & c & ext For Binary As newfile
handle2 = FileAttr(newfile, 2)
ret = hwrite(handle2, gptr, piclen) 'might be over 64K so use hwrite
ret = GlobalUnlock(hMem)
ret = GlobalFree(hMem)
Close newfile
counter = counter + piclen
c = c + 1
Loop
Close #1
c = c - 1
Label1 = "You extracted " & c & " pictures"
End Sub
Sub mnuFile_Click ()
Dim fname$, num%
On Error Resume Next
CMDialog1.CancelError = True
CMDialog1.DialogTitle = "Open FRX File"
CMDialog1.Filter = "FRX Files | *.frx"
CMDialog1.Flags = &H1&
CMDialog1.Action = 1
If Err = 0 Then
fname = CMDialog1.Filename
If Right$(Trim$(fname), 3) <> "FRX" Then
MsgBox "This only works on frx files"
Exit Sub
End If
ExtractPictures fname
End If
End Sub